package com.wang.controller;

import com.wang.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * Created by wangq on 2021/8/20.
 */
@Controller
@RequestMapping(value = "login")
public class LoginController {
    @Autowired
    LoginService loginService;

    @GetMapping(value = "toLogin")
    private String toLogin() {
        System.out.println("请求跳转到登录页。。。");
        return "login";
    }

    @RequestMapping("result")
    public String result() {
        System.out.println("跳转到成功页。。。");
        return "result";
    }

    @PostMapping(value = "loginSystem")
    private String login(String username, String password, HttpSession httpSession) {
        System.out.println("用户登录：" + username);
        return loginService.login(username, password, httpSession);
    }
}
